home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / cacheClipData.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.5 KB  |  117 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17.     //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct, 2000
  22. //  Author:         bb
  23. //
  24. //    Procedure Name:
  25. //        cacheClipData
  26. //
  27. //    Description:
  28. //        Callback used before removing attributes from a character
  29. //      to cache clip data for the attributes. The 
  30. //        clip data is isolated separate from the character in a
  31. //        clipLibrary from which it can be copied and pasted
  32. //        onto a new character using copyCachedClipDataCallback.
  33. //
  34. //    Input Arguments:
  35. //    $character :      name of the original character
  36. //  $attrs :         attributes to be cached
  37. //
  38. //    Return Value:
  39. //        Library file and clip names for the cached clips
  40. //
  41. global proc string[]
  42. cacheClipDataForCharacter(string $character, string $attrs[])
  43. {
  44.     // Isolate any clips for channels that we want to copy to the other
  45.     // new subcharacter
  46.     //
  47.     string $isolateResult[];
  48.     if (size($attrs) > 0) {
  49.         string $sch = `character -q -sc $character`;
  50.         if (size($sch) > 0) {
  51.             string $schedClips[] = `clipSchedule -q -n $sch`;
  52.             if (size($schedClips) > 0) {
  53.                 string $isolateCmd = "clip -ignoreSubcharacters -isolate";
  54.                 for ($sc in $schedClips) {
  55.                     $isolateCmd += (" -name "+$sc);
  56.                 }
  57.                 for ($aic in $attrs) {
  58.                     $isolateCmd += (" -uc "+$aic);
  59.                 }
  60.                 $isolateCmd += (" "+$character);
  61.                 $isolateResult = eval($isolateCmd);
  62.             }
  63.         }
  64.     }
  65.     return $isolateResult;
  66. }
  67.  
  68. global proc string[]
  69. cacheClipData(string $character, string $attrs[])
  70. {
  71.     string $result[];
  72.     
  73.     // If the character isn't specified, find out if the attributes are in
  74.     // a character
  75.     //
  76.     if ("" == $character) {
  77.         int $ii, $jj;
  78.         int $atCount = size($attrs);
  79.         string $myAttrs[];
  80.         string $myChars[];
  81.         for ($ii = 0; $ii < $atCount; $ii++) {
  82.             string $mem[] = `listConnections -d 1 -s 0 -type character $attrs[$ii]`;
  83.             if (size($mem)) {
  84.                 $myAttrs[$ii] = $attrs[$ii];
  85.                 $myChars[$ii] = $mem[0];
  86.             } else {
  87.                 $myAttrs[$ii] = "";
  88.                 $myChars[$ii] = "";                
  89.             }
  90.         }
  91.         for ($ii = 0; $ii < $atCount; $ii++) {
  92.             string $attrsToAdd[];
  93.             if ($myAttrs[$ii] == "") continue;
  94.  
  95.             $attrsToAdd[0] = $myAttrs[$ii];
  96.             string $currChar = $myChars[$ii];
  97.             for ($jj = 0; $jj < $atCount; $jj++) {
  98.                 if ($myChars[$jj] == $currChar) {
  99.                     $attrsToAdd[size($attrsToAdd)] = $myAttrs[$jj];
  100.                     $myAttrs[$jj] = "";
  101.                     $myChars[$jj] = "";
  102.                 }
  103.             }
  104.             string $currR;
  105.             string $currResult[];
  106.             $currResult = cacheClipDataForCharacter($currChar,$attrsToAdd);
  107.             for ($currR in $currResult) {
  108.                 $result[size($result)] = $currR;
  109.             }
  110.             clear($attrsToAdd);
  111.         }
  112.     } else {
  113.         $result = cacheClipDataForCharacter($character,$attrs);
  114.     }
  115.     return $result;
  116. }
  117.